<template>
    <el-menu default-active="1-4-1" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff"
        active-text-color="#ffd04b" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
        <h3>{{ isCollapse ? '后台' : '后台管理系统' }}</h3>
        <!-- <template v-for="item in menu"> -->
        <router-link v-for="(item, index) in menu" :to="item.path" :key="item.path">
            <el-menu-item :index="index.toString()" >
                <i :class="'el-icon-' + item.icon"></i>
                <!-- <span slot="title">{{ item.label }}</span> -->
                {{ isCollapse ? '' : item.label }}
            </el-menu-item>
        </router-link>
        

    </el-menu>
</template>
  
<script>

export default {
    name: "CommonAside",
    data() {
        return {
            // isCollapse: false,
            menu: [
                {
                    path: '/',
                    name: 'home',
                    label: '首页',
                    icon: 's-home',
                    url: 'Home/Home'
                },
                {
                    path: '/goods',
                    name: 'goods',
                    label: '商品管理',
                    icon: 's-goods',
                    url: 'MallManage/MallManage'
                },

                {
                    path: '/params',
                    name: 'params',
                    label: '规格参数',
                    icon: 's-tools',
                    url: 'Params/Params'
                },

                {
                    path: '/advert',
                    label: '广告分类',
                    icon: 's-help',
                },
                {
                    path: '/user',
                    label: '个人中心',
                    icon: 'user',
                },
            ]
        };
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        },
        clickMenu(item) {
            this.$store.commit('selectMenu', item)
        }
    },
    computed: {
        noChirdren() {
            return this.menu.filter(item => !item.children)
        },
        hasChirdren() {
            return this.menu.filter(item => item.children)
        },
        isCollapse() {
            return this.$store.state.tab.isCollapse;
        },
        user() {
            return this.$store.getters.user
        }
    }

}
</script>
  
<style lang="less" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
}

.el-menu {
    height: 100%;
    border: none;

    h3 {
        color: #fff;
        text-align: center;
        line-height: 48px
    }
}
</style>